package com.situ.water_Invoice.mapper;

import com.situ.water_Invoice.pojo.FPJP;
import com.situ.water_Invoice.pojo.IvArchive;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.situ.water_Invoice.pojo.IvIninvoice;
import com.situ.water_Invoice.pojo.IvOutinvoice;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Angel
 * @since 2020-12-01
 */
@Mapper
public interface IvArchiveMapper extends BaseMapper<IvArchive> {

    //发票交票情况查询
    @Select("select iv_archive.id,iv_archive.startNo,iv_archive.endNo,iv_archive.ArCounts,iv_invoice.used,iv_Invoice.invalid,iv_archive.ArchiveDate,sy_emp.empNmae,o.empNmae ename from iv_archive left join iv_Invoice on iv_Invoice.ArchiveID=iv_archive.id left join sy_Emp on sy_Emp.id=iv_archive.ArchiveEmpID left join sy_emp o  on o.id=iv_archive.Empid")
    public List<FPJP> FPJP();

    //查询StartNo 比较数据库和输入框的StartNo (发票开始号码)
    @Select("SELECT * FROM Iv_Archive WHERE StartNo=#{value}")
    public IvArchive queryId(String StartNo);

    //发票交票
    @Insert("INSERT INTO Iv_Archive(EmpID,InID,StartNo,EndNo,ArCounts,ArchiveEmpID) VALUES(#{EmpID},#{InID},#{StartNo},#{EndNo},#{ArCounts},#{ArchiveEmpID})")
    public int addIvArchive(IvArchive ivArchive);

    //查询刚刚交票的id
    @Select("SELECT * from Iv_Archive ORDER BY ID DESC LIMIT 1")
    public IvArchive Ivinid();

}
